package com.osmino.contacts.view;

import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;

public class StateDrawable extends StateListDrawable {
		
	private final boolean DBG = true;
	private static final int PRESSED = android.R.attr.state_pressed;
	private static final int FOCUSED = android.R.attr.state_focused;
	private static final int IDLE = android.R.attr.state_enabled;
	
    public StateDrawable(Drawable[] layers) {
    	addState(new int[]{PRESSED, FOCUSED}, layers[0]);
    	addState(new int[]{IDLE}, layers[1]);
    	setState(new int[]{IDLE});
    }

    @Override
    protected boolean onStateChange(int[] states) {
        for (int state : states) {
            if (state == PRESSED || state == FOCUSED) {
            	setState(new int[]{PRESSED, FOCUSED});
            	return true;
            }
        }
        setState(new int[]{IDLE});
        return true;
    }

    @Override
    public boolean isStateful() {
        return true;
    }

}